<header class="site-header">

    <div class="container"> <!-- container-fluid px-lg-5 -->
	    <div class="navbar">
	      <div class="logo-wrapper">
	      	<?php
		    $logo_img = _cao('site_logo', '');
			$blog_name = get_bloginfo('name');
			$home_url = esc_url(home_url('/'));
		    if (!empty($logo_img)) {
			  $logo_html = sprintf('<img class="logo regular" src="%s" alt="%s">', esc_url($logo_img), esc_attr($blog_name));
			} else {
			  $logo_html = sprintf('<span class="logo text">%s</span>', esc_html($blog_name));
			}
			printf('<a rel="nofollow noopener noreferrer" href="%s">%s</a>', esc_url(home_url('/')), $logo_html);
			?>
		  </div>

	      <div class="sep"></div>
	      
	      <nav class="main-menu d-none d-lg-block">
	        <?php 
	        // 定义缓存的ID和过期时间
			$cache_id = 'main-menu-cache';
			$cache_expiration = 5 * 24 * 3600; // 缓存一天
			// 尝试从缓存获取菜单
			$cached_menu = get_transient( $cache_id );
			// 如果没有缓存，重新生成并缓存菜单
			if ( false === $cached_menu ) {
			    
			    $cached_menu = wp_nav_menu( array(
		          'container' => true,
		          'fallback_cb' => 'ZB_Walker_Nav_Menu::fallback',
		          'menu_id' => 'header-navbar',
		          'menu_class' => 'nav-list',
		          'theme_location' => 'main-menu',
		          'walker' => new ZB_Walker_Nav_Menu( true ),
		          'echo' => false, // 返回html内容
		        ) );

			    set_transient( $cache_id, $cached_menu, $cache_expiration );
			}
			// 输出菜单
			echo $cached_menu;

	        ?>
	      </nav>
	      
	      <div class="actions">
	                    <?php if ( _van('is_header_vip_logo',1) && !_cao('is_login_site_shop') ) : ?>
				<span class="fuid-vip-link"><a href="<?php echo _van('header_vip_logo_link',1) ?>"><?php echo '<img src="' . get_stylesheet_directory_uri() . '/assets/images/home/nav-vip.svg">' ?> 成为VIP</a></span>
				
				<?php endif;?>
	        <?php get_template_part( 'template-parts/header/action-hover'); ?>
	        <div class="burger d-flex d-lg-none"><i class="fas fa-bars"></i></div>
	      </div>
	      <?php if ( empty(_cao('remove_site_search',false)) ) : ?>
	      <div class="navbar-search"><?php get_search_form();?></div>
		  <?php endif;?>
	      
	    </div>
    </div>

</header>

<div class="header-gap"></div>

